class Person {
    name: string
    age: number
    constructor(name: string, age: number) {
        this.name = name
        this.age = age
    }
}


class Student extends Person {
    score: number
    constructor(name: string, age: number, score: number) {
        super(name, age)
        this.score = score
    }
}
let p: Person = new Person("jack", 20)
let s: Student = new Student("rose", 20, 77)
p as Student
s as Person


//  接口之间也可以继承
interface IPerson {
    name: string;
    // age: number;
}

interface IStudent extends IPerson {
    score: number
}


// 在typescript中，接口可以继承类
interface IStudent extends Person {
    score: number
}

// js中  不能多重继承，父类只能有一个
// 类 可以实现（implement）接口 

interface ICanFly {
    fly(): void    // 飞行的方法
}

class SuperMan extends Person implements ICanFly {
    fly() {
        console.log('超人是可以飞的')
    }
}

const sm = new SuperMan("克拉克", 300)
sm.fly()

sm as Person
sm as ICanFly


export default null


